//
//  CustomCollectionViewCell.m
//  releaseInterface
//
//  Created by Gamefire on 16/4/14.
//  Copyright © 2016年 Gamefire. All rights reserved.
//

#import "CustomCollectionViewCell.h"


@interface CustomCollectionViewCell ()
{
    UIImageView *imageView;
    UIButton *deleteButton;
    
}

@end


@implementation CustomCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setBackgroundColor:[UIColor redColor]];
        
        UIImage *image = [UIImage imageNamed:@"uploadimageguanbi"];
        deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, image.size.height)];
        [deleteButton setImage:image forState:UIControlStateNormal];
        [deleteButton setHidden:YES];
//        [deleteButton setBackgroundColor:[UIColor redColor]];
        
        
        imageView = [[UIImageView alloc] initWithFrame:self.bounds];
        [self addSubview:imageView];
        [self addSubview:deleteButton];
        [deleteButton addTarget:self action:@selector(shanchuZhaopian:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}


- (void)setTag:(NSInteger)tag
{
    [deleteButton setTag:tag];
}

- (void)loadImage:(UIImage *)image withChange:(BOOL)change
{
    [imageView setImage:image];
    if (change)
    {
        [deleteButton setHidden:NO];
    }
    else
    {
        [deleteButton setHidden:YES];
    }
}


- (void)shanchuZhaopian:(UIButton *)sender
{
    if (_MCustomCollectionViewCellDelegate && [_MCustomCollectionViewCellDelegate respondsToSelector:@selector(shanchu:)]) {
        [_MCustomCollectionViewCellDelegate shanchu:sender.tag];
    }
}

@end
